﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace LprMiddleWare
{
    internal class TestUploadWebservice
    {
        public Task<string> TestUploadServiceAsync(string url, string sn, string dwdm, string lry)
        {

            var xml = new XmlDocument();
            xml.Load("UploadTemplate.xml");
            var root = xml.DocumentElement;
            var imgPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images/TestPlate.jpg");
            var zjwj = Convert.ToBase64String(System.IO.File.ReadAllBytes(imgPath));
            root["peccancydzy"]["zjwj1"].InnerText = zjwj;
            root["peccancydzy"]["zjwj2"].InnerText = zjwj;
            root["peccancydzy"]["lry"].InnerText = lry;

            var service = new Services.dyService();
            service.Url = url;
            return TaskEx.Run(() => service.Upload(xml.OuterXml, sn, dwdm));

        }
    }
}
